package org.yourscrum.web;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.yourscrum.domain.Theme;
import org.yourscrum.service.ThemeService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author Jettro Coenradie
 */
public class ThemeController extends AbstractController {
    private ThemeService themeService;

    public ThemeController(ThemeService themeService) {
        this.themeService = themeService;
    }


    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        List<Theme> themes = themeService.obtainThemes();
        ModelAndView mav = new ModelAndView("themes");
        mav.addObject("themes", themes);
        return mav;
    }
}
